import { defineConfig, loadEnv } from 'vite'
import checker from 'vite-plugin-checker'
import viteCompression from 'vite-plugin-compression';
import importToCDN from 'vite-plugin-cdn-import'



export default defineConfig(({ command, mode }) => {

    loadEnv(mode, process.cwd())

    return {
        server:{
            proxy:{
                '/api': {
                    target: 'http://jsonplaceholder.typicode.com',
                    changeOrigin: true,
                    rewrite: (path) => path.replace(/^\/api/, ''),
                  },
            }
        },
        plugins: [
            checker({
                typescript: true,
            }),
            
            importToCDN({
                modules: [
                    {
                        name: 'lodash',
                        var: '_',
                        path: 'https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js'
                    }
                ]
            })
        ]
    }
})


